<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('问题列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list" style="width: 742px; margin: 0 auto; padding-top: 10px;">
                    <ul>
                        <li>
                            <label class="col-sm-4 control-label" style="margin-top: 10px; padding-right: 0px;">问题类型：</label>
                            <div class="col-sm-8" style="padding-top: 3px;  padding-left: 0; ">
                                <select name="questionType" class="form-control" style="padding-top: 3px; padding-left: 0; ">
                                    <option value="">请选择</option>
                                    <option value="2">处理</option>
                                    <option value="3">解释</option>
                                </select>
                            </div>
                        </li>
                        <li>
                            <label class="col-sm-4 control-label" style="margin-top: 10px; padding-right: 0px;">问题版本号：</label>
                            <div class="col-sm-8" style="padding-top: 3px;  padding-left: 0;">
                                <select name="questionVersion" class="form-control" th:with="type=${@dict.getType('df_question_version')}" style="padding-top: 3px;">
                                    <option value="">请选择</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </div>
                        </li>
                        <li>
                            <!--<label class="col-sm-5 control-label">问题标题：</label>-->
                            <input type="text" name="questionTitle" style="width: 600px; margin-left: 13px;">
                        </li>
                        <li style="float: right; margin-top: -62px;">
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()" style="width: 100px;"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <!--<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>-->
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="question:dfQuestion:add">
                <i class="fa fa-plus"></i> 提问
            </a>
            <!--<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="question:dfQuestion:edit">-->
                <!--<i class="fa fa-edit"></i> 修改-->
            <!--</a>-->
            <!--<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="question:dfQuestion:remove">-->
                <!--<i class="fa fa-remove"></i> 删除-->
            <!--</a>-->
            <a class="btn btn-warning" onclick="$.table.importExcel('importForm')">
            <i class="fa fa-upload"></i> 导入
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('question:dfQuestion:edit')}]];
    var removeFlag = [[${@permission.hasPermi('question:dfQuestion:remove')}]];
    var prefix = ctx + "question/dfQuestion";

    var states = [[${@dict.getType('df_question_state')}]];
    var types = [[${@dict.getType('df_question_type')}]];
    var versions = [[${@dict.getType('df_question_version')}]];
    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            modalName: "问题",
            showExport: false,
            importUrl: prefix + "/importData",
            importTemplateUrl: prefix + "/importTemplate",
            columns: [
            //     {
            //     checkbox: true
            // },

                {
                    field : 'questionNumber',
                    title : '问题编号',
                    sortable: true
                },
                // {
                //     field : 'userDept',
                //     title : '用户单位',
                //     sortable: true
                // },
                {
                    field : 'questionTitle',
                    title : '问题',
                    sortable: true

                },
                {
                    field : 'createtime',
                    title : '创建时间',
                    sortable: true,
                    formatter: function(value, row, index) {
                        var sdate = new Date(row.createtime);
                        var now = new Date();
                        var days = now.getTime() - sdate.getTime();
                        var day = parseInt(days / (1000 * 60 * 60 * 24));
                        if (row.questionState=='0' || row.questionState=='1'  || row.questionState=='2'){
                            if (day>15){
                                return '<label class="badge badge-danger" >'+row.createtime+'</label>';
                            } else if (day>7){
                                return '<label class="badge badge-warning-light">'+row.createtime+'</label>';
                            }else {
                                return '<label class="badge badge-info" >'+row.createtime+'</label>';
                            }
                        } else{
                            return '<label class="badge badge-info" >'+row.createtime+'</label>';
                        }
                    }
                },
                {
                    field : 'questionType',
                    title : '问题类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(types, value);
                    }
                },
                {
                    field : 'questionVersion',
                    title : '问题版本',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(versions, value);
                    }
                },

                {
                    field : 'updatetime',
                    title : '解决时间',
                    sortable: true
                },
                {
                    field : 'questionState',
                    title : '状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(states, value);
                    }
                },
                {
                    title: '操作',
                    align: 'left',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="look('+row.id+')"><i class="fa fa-eye"></i>查看</a> ');
                        if (row.questionState == "9"){
                            actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="comment('+row.id+')"><i class="fa fa-comment"></i>评价</a> ');
                        }
                        if (row.questionState == "0"||row.questionState == "10") {
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        }
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="questionSchedule('+row.id+')"><i class="fa fa-eye"></i>进度</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
    function look(id) {
        $.modal.look("查看问题",prefix+"/view/"+id);
    }
    function comment(id) {
        $.modal.look("问题评论",prefix + "/comment/"+id);
    }
    //查看问题进度
    function questionSchedule(id){
        $.modal.look("查看问题进度",prefix + "/checkSchedule/"+id,825);
    }
</script>
</body>

<form id="importForm" enctype="multipart/form-data" class="mt20 mb10" style="display: none;">
    <div class="col-xs-offset-1">
        <input type="file" id="file" name="file"/>
        <div class="mt10 pt5">
            <input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在，更新这条数据。"> 是否更新已经存在的问题数据
            &nbsp;	<a href="http://211.149.205.33:18080/file/down/190923154843466" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
        </div>
        <font color="red" class="pull-left mt10">
            提示：仅允许导入“xls”或“xlsx”格式文件！
        </font>
    </div>
</form>
</html>